package com.lyw.springCloud.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.cloud.stream.messaging.Sink;
import org.springframework.messaging.Message;
import org.springframework.stereotype.Component;

/**
 * @Auther liyawei
 * @Date 2022/5/14 11:40
 */

@Component
@EnableBinding(Sink.class)
public class ReceiveMessageListenerController {

    @Value("${server.port}")
    private String serverPort;

    @StreamListener(Sink.INPUT) // 监听的数据源
    public void input(Message<String> message) {
        System.out.println("接收到的消息，----> " + message.getPayload() + "server port ---> " + serverPort);
    }
}
